#ifndef GAME_H
#define GAME_H

#include "OpenGLRenderer.h"
#include "Timer.h"
#include "Input.h"
//#include "TextureHandler.h"
//#include "Timer.h"
#include "Network.h"

#include "GameObject.h"

#include "Maths.h"

#include <vector>

class CGame
{
    
    static CGame* m_pInstance;
    
    //CGame() : m_pInstance(0) 		{}
    ~CGame()
    {
		delete m_pInstance;
	}
    
    public:
        
        static CGame* getInstance()
        {
            
            //static CGame instance;
            //return &instance;
            if (!m_pInstance)
            	return m_pInstance = new CGame();
            return m_pInstance;
            
        }
        
        void run();
        
        CGameObject* addGameObject(CGameObject* pObject)        { m_pObjects.push_back(pObject); return m_pObjects.back(); }
        
        //CPlayer* getLocalPlayer()       { return m_pLocalPlayer; }
        
        CTimer* getTimer()            { return m_pTimer; }
        CMultiplayer* getMultiplayer()      { return m_pMultiplayer; }
        
    private:
        
        void init();
        void update(Scalar fTimeStep);
        void draw();
        void shutdown();
        
        //Game components
        CRenderer* m_pRenderer;
        CInput* m_pInput;
        CTimer* m_pTimer;
        CMultiplayer* m_pMultiplayer;
        
        //Pointer to the local player class
        //CPlayer* m_pLocalPlayer;
        
        //Array of all game objects
        std::vector<CGameObject*> m_pObjects;
        
};

#endif //GAME_H
